<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="js/vue.js"></script>
    <style>
        .active{
            background-color: cornflowerblue;
        }
    </style>
</head>
<body>
    <div id="box">
        <input type="text" @input="handleInput">
        <ul>
            <li v-for="item in list">
                {{item}}
            </li>
        </ul>
    </div>
    <script>
        var vm = new Vue({
            el:"#box",
            data:{
                list:["aaa","bbb","abc","bac","bbc","cbb","ccc"],
                //备份原始数据
                originList:["aaa","bbb","abc","bac","bbc","cbb","ccc"]
            },
            methods:{
                handleInput(eve){
                    //使用filter过滤备份的数组
                     var newArr = this.originList.filter(item=>item.includes(eve.target.value));
                     //过滤后的数据交给页面渲染的数组
                     this.list = newArr;
                }
            }
        })
    </script>
</body>
</html>